package cn.echisan.homework.interceptor;

import cn.echisan.homework.utils.CommonUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by echisan on 2018/6/4
 */
public class CommonInterceptor extends HandlerInterceptorAdapter {

    @Override
    public void postHandle(HttpServletRequest request,
                           HttpServletResponse response,
                           Object handler, ModelAndView modelAndView) throws Exception {
        String uri = request.getRequestURI();
        if (uri.contains("home")){
            modelAndView.addObject("commons", new CommonUtils());
        }
        super.postHandle(request, response, handler, modelAndView);
    }
}
